SWAGOLX.EXE (c) 1993 GDSOFT ALL RIGHTS RESERVED 00007 1 08-24-9413:27ALL ROBBIE FLYNN Caps SWAG9408 j|M[ 13 {πhereya go. I've found that these come in pretty handy. You can makeπsome cool things with them too. I also have the code to detect ifπthe lights are on/off also if you want it.π}πuses crt; Procedure TurnCapsOn;Assembler;πASMππ SUB AX,AXπ MOV ES,AXπ MOV AL,64π OR ES:[417h],ALπ RETπEND;ππProcedure TurnNumOn;Assembler;πASMππ SUB AX,AXπ MOV ES,AXπ MOV AL,32π OR ES:[417h],ALπ RETπEND;ππProcedure TurnScrollOn;Assembler;πASMππ SUB AX,AXπ MOV ES,AXπ MOV AL,16π OR ES:[417h],ALπ RETπEND;ππProcedure TurnCapsOff;Assembler;πASMππ SUB AX,AXπ MOV ES,AXπ MOV AL,10111111bπ AND ES:[417h],ALπ RETπEND;ππProcedure TurnNumOff;Assembler;πASMππ SUB AX,AXπ MOV ES,AXπ MOV AL,11011111bπ AND ES:[417h],ALπ RETπEND;ππProcedure TurnScrollOff;Assembler;πASMππ SUB AX,AXπ MOV ES,AXπ MOV AL,11101111bπ AND ES:[417h],ALπ RETπEND;ππvarπ x : integer;π{Watch your lights} beginπ x:=0;π repeatπ inc(x);π if x mod 3 = 0 thenπ Begin TurnNumOn;TurnCapsOff;TurnScrollOff;π End;π If X mod 3 = 1 thenπ Beginπ TurnNumOff;TurnCapsOn;TurnScrollOff;π End;π If X Mod 3 = 2 thenπ Beginπ TurnNumOff;TurnCapsOff;TurnScrollOn;π End;π Delay(115);π until keypressed;πend.π 2 08-24-9413:38ALL FLORIAN ANSORGE Keyboard lights SWAG9408 <B6╡ 9 {π ER> Anyway, Does anyone knows who to make the num/caps/scroll leds on theπ ER> keyboard 'flicker' or just light up?π}ππPROGRAM FlashLED;ππUSES DOS, Crt;ππCONSTπ LOCKSOFF = $8F; { Mask off all LEDs }π SCRLOCK = 16;π NUMLOCK = 32;π CAPLOCK = 64;ππVARπ KeyLocks : BYTE ABSOLUTE $0040:$0017; { LED bits at this FAR address }π SaveLock : BYTE; { Used to save LED status bits }ππ{ To make DOS cause LED update }πPROCEDURE DummyDosCall; ASSEMBLER;πasmπ mov ah, 11π int $21πEnd;ππVARπ Shift : BYTE; { Used in bit shifting of LEDs }ππBEGINπ { Store current state }π SaveLock := KeyLocks;π Shift := 1;ππ Repeatπ { Turn on the LED bit according to Shift }π KeyLocks := (SCRLOCK SHL Shift);ππ { Set Shift to indicate the LED to the right }π Shift := (Shift + 1) MOD 3;ππ { Allow DOS to update the LEDs }π DummyDosCall;ππ { Simple pause }π Delay( 200 );π Until KeyPressed;ππ { Restore original keyboard state }π KeyLocks := SaveLock;πEND.π 3 08-24-9413:44ALL ALEX GRISCHENKO Keyboard Unit SWAG9408 u■4ï 105 π{$X+,S-,R-,I-,L-,O-,B-,D-}π{*****************************************}π{* Keyboard unit for BP 7.0 *}π{* Direct INT 9h support *}π{* Written by Alex Grischenko *}π{* Modified by Olaf Bartelt for DPMI *}π{* (C) AntSoft Lab , 1994 *}π{* Version 1.0 30-06-94 *}π{*****************************************}ππUnit Keyboard;ππinterfaceππtypeπ DoubleKey = objectπ Left,Right : boolean;π function Both : boolean;π function Any : boolean;π end;ππ LockKey = recordπ Pressed,Locked : boolean;π end;ππ KeyEvent = recordπ case Integer ofπ 0: (KeyCode : Word);π 1: (CharCode: Char; ScanCode: Byte);π end;πππconstπ SEG0000 : WORD = $0000;ππ k_LShift = $2A00;π k_RShift = $3600;π k_LAlt = $3800;π k_RAlt = $3800 or $8000;π k_LCtrl = $1D00;π k_RCtrl = $1D00 or $8000;ππ k_PrtScr = $F900;π k_SysReg = $F800;π k_Pause = $F700;π k_Break = $F600;π k_CapsLock = $3A00;π k_NumLock = $4500;π k_ScrollLock = $4600;ππ k_AltCtrlDel = $F200;ππ WasKeybEvent : boolean = false; { Was event from keyboard }π Pressed : boolean = false; { TRUE - key pressed, FALSE - released }ππ ESC : boolean = false;π Alt : DoubleKey = ( Left : false; Right : false );π Ctrl : DoubleKey = ( Left : false; Right : false );π Shift : DoubleKey = ( Left : false; Right : false );π PrtScr : boolean = false;π CapsLock : LockKey = ( Pressed : false; Locked : false );π NumLock : LockKey = ( Pressed : false; Locked : false );π ScrollLock: LockKey = ( Pressed : false; Locked : false );π Pause : boolean = false;π CtrlBreak : boolean = false;ππ AltCtrlDel: boolean = false;ππprocedure InitKeyboard; { Initalize driver }πprocedure DoneKeyboard; { Uninstall driver }πfunction ReadKeyboard : byte; { Read current scancode from keyboardπ ( }πfunction KeyPressed : boolean; { Keys was pressed? }πfunction ReadKey : char; { For using instead CRT.ReadKey }πfunction ReadChar : char; { Converts scancode to ASC-key }πprocedure GetKeyEvent(var KEvent : KeyEvent);ππprocedure NullProc;π{procedure KeybLights(On : boolean; Light : byte);}ππconstπ AltCtrlDelproc : procedure = NullProc;π { Alt-Ctrl-Del Handler }ππimplementationππfunction DoubleKey.Both : boolean;πbeginπ Both:=Right and Left;πend;ππfunction DoubleKey.Any : boolean;πbeginπ Any:=Right or Left;πend;ππconstπ Key : byte = 0;π KeyboardSet : boolean = false;ππ KeyCodes : array [1..$58] of word = (ππ{******** 85 - key **********}π {ESC 1 2 3 4 5 6 7 8 9 0 - = BkSp}π 27, 49,50,51,52,53,54,55,56,57,48,45,61, 8,ππ {TAB Q W E R T Y U I O P [ ] Enter}π 9, 81,87,69,82,84,89,85,73,79,80,91,93, 13,ππ {LCtrl A S D F G H J K L ; ' `}π k_LCtrl,65,83,68,70,71,72,74,75,76,59,39,96,ππ {LShift \ Z X C V B N M , . / RShift}π k_LShift,92,90,88,67,86,66,78,77,44,46,47, k_RShift,ππ { * LAlt Space CapsLock}π 42, k_LAlt, 32, k_CapsLock,ππ {F1 F2 F3 F4 F5 F6 F7 F8 F9 F10}π $3B00,$3C00,$3D00,$3E00,$3f00,$4000,$4100,$4200,$4300,$4400,ππ { NumLock ScrollLock}π k_NumLock, k_ScrollLock,ππ {Home Up PgUp K - Left K 5 Right K +}π $4700,$4800,$4900,$4A2D,$4b00,$4c00,$4d00,$4e2b,ππ { End Down PgDn Ins Del}π $4f00,$5000,$5100,$5200,$5300,ππ{******** 101 - key **********}π {AltPrtScr F11 F12}π $5400, 0, 0, $5700, $5800);ππ ExtCode : byte = 0;π ExtExtCode : byte = 0;π Extent : boolean = false;ππvarπ oldint9seg,oldint9ofs : word;π Lights : byte ;π{ Queue : array[0..30] of byte;π} QHead,QTail : word;πππ{ - Wait keyboard }πprocedure WaitKeyb; near; assembler;πasmπ push axπ@@Wait:π in al,64hπ test al,02hπ loopnz @@Waitπ pop axπend;ππ{ - Send byte to keyboard port }πprocedure SendIt; near; assembler;πasmπ cliπ call WaitKeybπ out 64h,alπ stiπend;ππprocedure SetLights; near; assembler;πasmπ(*π push axπ mov al,0EDhπ{ call SendIt}π out 60h,alπ mov cx,200hπ@loop:π loop @loopπ mov al,Lightsπ{ call SendIt }π out 60h,alπ pop axπ*)πend;πππprocedure MyInt9(Flags, CS, IP, AX, BX,πCX, DX, SI, DI, DS, ES, BP: Word); interrupt;πlabel IntEnd,SendEOI;πbeginπ asmπ mov ax, seg @dataπ mov ds,axππ mov al,0adh { Disable keyboard }π call senditπ cliππ call WaitKeyb { Wait }ππ in al,60h { Get keycode }π stiπ mov key,al;ππpush axπmov al,0AEhπcall senditπmov al,20hπout 20h,alπpop axππ@@keyEvent:π mov WasKeybEvent,1 { Set event flag }ππ mov ah,alπ and ah,0F0h { Was extented keystroke ? }ππ cmp ah,0E0hπ jne @NormalCodeπ(* jne @CheckAA { no, check next ext. code AAh }ππ cmp ExtCode,0AAh { Was sequence E0 AA E0 ? }π jne @ExtCode { No, set as firts extent code }ππ mov Extent,0 { yes, clear exten flags }π mov ExtCode,0π{ mov al,91 { Return as Shift key pressed }π jmp IntEndπ*)π @ExtCode:π mov Extent,1 { yes, set flag and store extented code }π mov ExtCode,alπ mov WasKeybEvent,0π jmp IntEnd { finish interrupt }ππ @NormalCode:π mov ah,alπ and al,7Fh { mask low 7 bits }ππ cmp al,60hπ jb @@IsKeyππ cmp al,0A0hπ jb IntEndππ@@IsKey:π and ah,80h { check pressing }π je @@Pressedππ mov Pressed,0 { if higher bit set to 1, then key released }π jmp @@1ππ @@Pressed:π mov Pressed,1ππ @@1:π mov key,al { store key }π mov ah,Pressedππ{------------------------}π cmp al,1π jne @PrtScrπ mov ESC,ahπ jmp IntEndππ@PrtScr:π cmp al,37hπ jne @next0π cmp ExtCode,0E0hπ jne IntEndπ mov PrtScr,ahππ@next0:π cmp al,2ahπ jne @next1π cmp ExtCode,0E0hπ jne @ShiftLπ@ExtShift:π xor ax,axπ mov WasKeybEvent,alπ mov ExtCode,alπ mov key,alπ jmp IntEndπ@ShiftL:π mov Shift.Left,ahπ jmp IntEndππ@next1:π cmp al,36hπ jne @next2π cmp ExtCode,0E0hπ je @ExtShiftπ mov Shift.Right,ahπ jmp IntEndππ@next2:π cmp al,38hπ jne @next3π cmp ExtCode,0E0hπ je @RAltπ mov Alt.Left,ahπ jmp IntEndπ @Ralt:π mov Alt.Right,ahπ jmp @@ResetExtπππ@next3:π cmp al,1Dhπ jne @next4π cmp ExtCode,0E0hπ je @RCtrlπ mov Ctrl.Left,ahπ jmp IntEndπ @RCtrl:π mov Ctrl.Right,ahπ jmp @@ResetExtππ@next4:π cmp al,3ahπ jne @next5π mov CapsLock.Pressed,ahπ cmp ah,1π je IntEndπ xor CapsLock.Locked,1π xor Lights,4π mov ax,0AEhπ{ call SendIt}π call SetLightsπ jmp SendEOIππ@next5:π cmp al,45hπ jne @next6π mov NumLock.Pressed,ahπ cmp ah,1π je IntEndπ xor NumLock.Locked,1π xor Lights,2π mov ax,0AEhπ{ call SendIt }π call SetLightsπ jmp SendEOIππ@next6:π cmp al,46hπ jne @next7π mov ScrollLock.Pressed,ahπ cmp ah,1π je IntEndπ xor ScrollLock.Locked,1π xor Lights,1π mov ax,0AEhπ { call SendIt}π call SetLightsπ jmp SendEOIππ@@ResetExt:π xor ax,axπ mov ExtCode,alπ mov Extent,alπ jmp IntEndππ@next7:π cmp al,53hπ jne IntEndπ end;ππ AltCtrlDel:=pressed and Alt.Any and Ctrl.Any;ππ if AltCtrlDel then AltCtrlDelProc;ππIntEnd:πasmπ{ Interrupt end }{π mov al,0aehπ call sendit }πSendEOI: {π mov al,20hπ out 20h,al }π end;πend;πππprocedure InitKeyboard; assembler;πasmπ cmp KeyboardSet,0π jne @@Quitππ@ClearBufferLoop:π mov ah,1π int 16hπ jz @NoKeybπ xor ax,axπ int 16hπ jmp @ClearBufferLoopππ@NoKeyb:π mov ax,3509hπ int 21hπ mov oldint9seg,esπ mov oldint9ofs,bxππ push dsππ push csπ pop dsπ mov ax,2509hπ mov dx,offset MyInt9π int 21hπ pop dsππ cliπ xor ax,axπ mov QHead,axπ mov QTail,axπ mov Key,alππ xor ax,axπ mov es,SEG0000π mov al,byte ptr es:[417h]π mov cl,4π shr al,clπ mov Lights,alππ mov KeyboardSet,1π stiπ@@Quit:πend;ππprocedure DoneKeyboard; assembler;πasmπ cmp KeyboardSet,0π je @@Quitπ xor ax,axπ mov es,SEG0000π mov ax,word ptr es:[417h]π mov bl,Lightsπ mov cl,4π shl bl,clπ and al,10001111b { Set Lights status }π or al,blπ and ax,111110011110000bπ mov word ptr es:[417h],axπππ push dsπ mov dx,oldint9ofsπ mov ax,oldint9segπ mov ds,axπ mov ax,2509hπ int 21hπ pop dsπ@@Quit:πend;ππfunction ReadKeyboard : byte; Assembler;πasmπ xor ax,axπ mov al,Key;π mov Key,ah;π mov WasKeybEvent,ahπend;ππfunction KeyPressed : boolean;πbeginπ KeyPressed:=WasKeybEvent and Pressed;πend;ππfunction ReadKey : char;πbeginπ if KeyboardSet thenπ beginππ endπ else beginπ Writeln(#7'KEYBOARD.TPU Error : use InitKeyboard first!');π halt;π end;πend;ππfunction ReadChar : char; assembler;πconstπ scancode : char = #0;πasmπ cmp ScanCode,0 { if were extented keystrokes }π je @@NoScanCodeππ mov al,ScanCode { then return scan code }π mov ScanCode,0π jmp @@Quitππ@@NoScanCode:π mov al,0π cmp Key,0π je @@Quitππ mov bh,alπ mov bl,Keyπ dec blπ shl bx,1π mov ax,[offset KeyCodes + bx]ππ cmp al,0π jne @@Quitππ mov ScanCode,ahπ@@Quit:π mov key,0πend;ππprocedure GetKeyEvent( var KEvent : KeyEvent); assembler;πasmπ les di,KEventπ mov word ptr es:[di],0π cmp WasKeybEvent,0π je @Quitππ xor bx,bxπ mov bl,keyπ dec bxπ shl bx,1π mov ax,[offset KeyCodes + bx]ππ cmp al,0π je @Storeππ mov ah,keyπ@Store:π mov word ptr es:[di],axπ mov WasKeybEvent,0π mov Key,0π@Quit:πend;ππ{-------------------------------}πprocedure KeybLights(On : boolean; Light : byte);πvar L : byte;πbeginπ if (Light>7) then exit;π asmπ mov al,0EDhπ out 60h,alπ mov cx,2000hπ @loop:π loop @loopπ end;π if On then L := Lights or Lightπ else L := Lights and not Light;π port[$60]:=L;πend;ππ{-------------------------------}πprocedure NullProc;πbeginπend;ππvar OldExitProc : pointer;ππprocedure ExitProcedure; far;πbeginπ DoneKeyboard;π ExitProc:=OldExitProc;πend;ππFUNCTION get_selector(segment : WORD) : WORD;πVAR selector : WORD;πBEGINπ {$IFDEF DPMI}π ASMπ MOV AX, $0002π MOV BX, segmentπ INT $31π JNC @@1π MOV AX, segmentπ@@1:π MOV selector, AXπ END;π {$ELSE}π selector := segment;π {$ENDIF}ππ get_selector := selector;πEND;ππbeginπ SEG0000 := get_selector($0000);π OldExitProc:=ExitProc;π ExitProc:=@ExitProcedure;πend.ππ{ --------------------------- DEMO ------------------------------ }ππprogram KeybDemo;π{ Copyright (c) 1994 by Andrew Eigus Fidonet: 2:5100/33 }ππuses Crt, Keyboard;ππconstπ Status : array[Boolean] of String[11] = ('Not pressed', 'Pressed ');π Lock : array[Boolean] of String[10] = ('Not locked', 'Locked ');ππvarπ key : KeyEvent;π ch : char;π CursorShape : word;ππProcedure SetCursor(CursorOnOff : boolean); assembler;πAsmπ CMP CursorOnOff,Trueπ JNE @@2π CMP BYTE PTR [LastMode],Monoπ JE @@1π MOV CX,0607hπ JMP @@4π@@1:π MOV CX,0B0Chπ JMP @@4π@@2:π CMP BYTE PTR [LastMode],Monoπ JE @@3π MOV CX,2000hπ JMP @@4π@@3:π XOR CX,CXπ@@4:π MOV AH,01hπ XOR BH,BHπ INT 10hπEnd; { SetCursor }ππprocedure AltCtrlDelp; far;πbeginπ Writeln(#13#10#10'That was it. Not bad, eh?');π SetCursor(True);π Halt(1)πend;ππProcedure WriteXY(X, Y : byte; S : string);πBeginπ GotoXY(X, Y);π Write(S)πEnd; { WriteXY }ππFunction Hex(W : Word) : string;πconst hexChars: array [0..$F] of Char = '0123456789ABCDEF';πBeginπ Hex[0] := #4;π Hex[1] := hexChars[Hi(W) shr 4];π Hex[2] := hexChars[Hi(W) and $F];π Hex[3] := hexChars[Lo(W) shr 4];π Hex[4] := hexChars[Lo(W) and $F]πEnd; { Hex }ππBeginπ InitKeyboard;π AltCtrlDelproc:=AltCtrlDelp;π SetCursor(False);π TextAttr := LightGray;π ClrScr;π WriteLn('Keyboard unit demo by Andrew Eigus (c) 1994 Fidonet: 2:5100/33');π WriteLn('Hit any key to scan or Ctrl-Alt-Del to quit.');π repeatπ GetKeyEvent(Key);ππ WriteXY(1, 5, 'Left Shift state : ' + Status[Shift.Left]);π WriteXY(35, 5, 'Right Shift state : ' + Status[Shift.Right]);π WriteXY(1, 6, 'Left Alt state : ' + Status[Alt.Left]);π WriteXY(35, 6, 'Right Alt state : ' + Status[Alt.Right]);π WriteXY(1, 7, 'Left Ctrl state : ' + Status[Ctrl.Left]);π WriteXY(35, 7, 'Right Ctrl state : ' + Status[Ctrl.Right]);π WriteXY(1, 9, 'Scroll Lock state : ' + Status[ScrollLock.Pressed]);π WriteXY(35, 9, 'Scroll Lock toggle : ' + Lock[ScrollLock.Locked]);π WriteXY(1, 10, 'Num Lock state : ' + Status[NumLock.Pressed]);π WriteXY(35, 10, 'Num Lock toggle : ' + Lock[NumLock.Locked]);π WriteXY(1, 11, 'Caps Lock state : ' + Status[CapsLock.Pressed]);π WriteXY(35, 11, 'Caps Lock toggle : ' + Lock[CapsLock.Locked]);π WriteXY(1, 13, 'PrtScr key state : ' + Status[PrtScr]);π if Key.ScanCode and $F0 = $E0 thenπ WriteXY(1, 15, 'Key code : ' + Hex(Key.ScanCode))π elseπ beginπ WriteXY(1, 16, 'Scan code : ' +π Hex(Key.ScanCode and $7F) + ',' + Hex(Key.ScanCode and $7F));π WriteXY(35, 16, 'Key state : ' + Status[Pressed])π end;ππ WriteXY(1, 17, 'Key ASCII code : "' +π Key.CharCode + '",' + Hex(Byte(Key.CharCode)));ππ repeat until WasKeybEventπ until FalseπEnd.ππ 4 08-24-9413:45ALL DAVID DUNSON LiteShow (LED) SWAG9408 ¢c≈ 7 {π ER> Anyway, Does anyone knows who to make the num/caps/scrollπ ER> leds on the keyboard 'flicker' or just light up? (You couldπ ER> create pretty cool effects like a 'walking light' on onesπ ER> keyboard..:) I checked the SWAGfiles but was not able toπ ER> find anything there..π}πProgram LiteShow;πUses Crt;ππVarπ i : Byte;ππProcedure SetLED(LED: Byte); Assembler;πASMπ MOV AL, $EDπ OUT $60, ALπ MOV CX, $200π@@1:π LOOP @@1π MOV AL, LEDπ OUT $60, ALπEnd;ππBeginπ i := 1;π While not KeyPressed doπ Beginπ SetLED(i);π i := i SHL 1;π If i = 8 then i := 1;π Delay(200);π End;π While KeyPressed do ReadKey;πEnd.π 5 08-24-9417:53ALL VARIOUS Set Typo rate and Delay SWAG9408 C½ 12 {π IL> INT 16 - KEYBOARD - SET TYPEMATIC RATE AND DELAYππI wrote a little utility a long time ago, that you might find a bit handy...πI'm sure I have the code around here somewhere (rummage..) Ah here :ππfor the typematic, delay is in increments of 250, and rate is in decrementsπof one...πSean Graham.....π}ππprocedure cursor(t, b: byte); assembler; { Set cursor attribs }πasmπ mov ax, $0100π mov ch, tπ mov cl, bπ int $10πend;ππprocedure v50; assembler; { Go to 50 line mode }πasmπ mov ax,1202hπ mov bl,30hπ int 10hπ mov ax,3π int 10hπ mov ax,1112hπ xor bl, blπ int 10hπend;ππprocedure v25; assembler; { Go to 25 line mode }πasmπ mov ax,$0003π int $10πend;ππprocedure typematic(rate, delay: byte); assembler;πasmπ mov ah, 3π mov al, 5 {Set Typematic Rate And Delay }π mov bh, rate {00h = 30/sec to 1fh = 2/sec }π mov bl, delay {00h = 250ms to 03h = 1000ms }π int $16πend;πππ {Int $16 Function $03; { Set type matic Rate }π {MAYNARD PHILBROOK,Re Keyboard Speed Adjust}ππ Procedure SetTypeRate(Kdelay, Krate:Byte);π Beginπ asmπ Mov AX,$0305; { on a PC jr, AL reg has extra Functions }π Mov BH, Kdelay;π Mov BL, Krate;π Int $16;π End;π End;π 6 08-25-9409:05ALL TIMO SALMI CTRL-BREAK/C disabling SWAG9408 £ < 27 (*π:Could someone please tell me how to disable CTRL-BREAK/C in my program so theπ:user cannot exit without using my "exit" option? The DOS BREAK=OFF justππThe mother of all TP FAQs :-)ππ-From: garbo.uwasa.fi:/pc/ts/tsfaqp20.zip Frequently Asked TP Questionsπ-Subject: Disabling or capturing the break keyππ1. *****π Q: I don't want the Break key to be able to interrupt my TPπprograms. How is this done?π Q2: I want to be able to capture the Break key in my TP program.πHow is this done?π Q3: How do I detect if a certain key has been pressed?ππ A: This very frequently asked question is basically a case of RTFMπ(read the f*ing manual). But this feature is, admittedly, not veryπprominently displayed in the Turbo Pascal reference. (As a generalπrule we should not use the newsgroups as a replacement for ourπpossibly missing manuals, but enough of this line.)π There is a CheckBreak variable in the Crt unit, which is true byπdefault. To turn it off useπ uses Crt;π :π CheckBreak := false;π :πBesides turning off break checking this enables you to capture theπpressing of the break key as you would capture pressing ctrl-c. Inπother words you can use e.g.π :πprocedure TEST;πvar key : char;πbeginπ repeatπ if KeyPressed thenπ beginπ key := ReadKey;π case key ofπ #3 : begin writeln ('Break'); exit; end; {ctrl-c or break}π else write (ord(key), ' ');π end; {case}π end; {if}π until false;πend;π :πIMPORTANT: Don't test the ctrl-break feature just from within the TPπIDE, because it has ctlr-break handler ("intercepter") of its ownπand may confuse you into thinking that ctrl-break cannot beπcircumvented by the method given above.π The above example has a double purpose. It also shows theπrudiments how you can detect if a certain key has been pressed. Thisπenables you to give input without echoing it to the screen, which isπa later FAQ in this collection.π This is, however, not all there can be to break checking, sinceπthe capturing is possible only at input time. It is also possible toπwrite a break handler to interrupt a TP program at any time. Forπmore details see Ohlsen & Stoker, Turbo Pascal Advanced Techniques,πChapter 7. (For the bibliography, see FAQPASB.TXT in this same FAQπcollection).ππ A2: Here is an example code for disabling Ctrl-Break and Ctrl-Cπwith interruptsπ*)π uses Dos;π var OldIntr1B : pointer; { Ctrl-Break address }π OldIntr23 : pointer; { Ctrl-C interrupt handler }π answer : string; { For readln test }π {$F+}π procedure NewIntr1B (flags,cs,ip,ax,bx,cx,dx,si,di,ds,es,bp : word);π Interrupt;π {$F-} begin end;π {$F+}π procedure NewIntr23 (flags,cs,ip,ax,bx,cx,dx,si,di,ds,es,bp : word);π Interrupt;π {$F-} begin end;π beginπ GetIntVec ($1B, OldIntr1B);π SetIntVec ($1B, @NewIntr1B); { Disable Ctrl-Break }π GetIntVec ($23, OldIntr23);π SetIntVec ($23, @NewIntr23); { Disable Ctrl-C }π writeln ('Try breaking, disabled');π readln (answer);π SetIntVec ($1B, OldIntr1B); { Enable Ctrl-Break }π SetIntVec ($23, OldIntr23); { Enable Ctrl-C }π writeln ('Try breaking, enabled');π readln (answer);π writeln ('Done');π end.π 7 08-25-9409:12ALL KEV1N@AOL.COM Stuffing Keyboard SWAG9408 e£ 19 {π> How do I stuff a string into the keyboard buffer?ππI've got two things for you:ππ1: Turbo Power's Object Professional's OpCRT unit has the followingπuseful routines:πprocedure StuffKey(W : Word);π {-Stuff one key into the keyboard buffer}ππprocedure StuffString(S : string);π {-Stuff the contents of S into the keyboard buffer}ππ{π2: If you don't have Object Professional (it's $895.00 but worth it)πBefore I noticed that OpCRT would do what I needed, I sat down andπwrote the following code. It's rough, but gives a pretty good ideaπof how the keyboard buffer works, and there's a chance that you canπuse it to create your own Stufferπ}πprogram ViewKbdBufr;ππ(********************************************************************π***π Written By Kevin R. Pierce - June 25, 1994π*********************************************************************π**)ππUsesπ OpString, {This is where HexB is. You can write your own easyπenough}π CRT;ππvarπ Buffer_Head : Byte absolute $0040:$001A;π Buffer_Tail : Byte absolute $0040:$001C;π Buffer_Start: Byte absolute $0040:$0080;π Buffer_End : Byte absolute $0040:$0082;ππ varπ t : byte;ππbeginπ clrscr;π repeatπ gotoxy(1,1);π writeln('Buffer Head = ',HexB(Buffer_Head));π writeln('Buffer Tail = ',HexB(Buffer_Tail));π writeln('Buffer Start = ',HexB(Buffer_Start));π writeln('Buffer End = ',HexB(Buffer_End));π writeln;π if Buffer_Tail >Buffer_Head then {simple list}π beginπ for t:=Buffer_Head to Buffer_Tail doπ write(Byte(Ptr(Seg0040,t)^):4);π endπ else {loop back to START}π if Buffer_Head<>Buffer_Tail thenπ beginπ for t:=Buffer_Head to Buffer_End doπ write(Byte(Ptr(Seg0040,t)^):4);π for t:=Buffer_Start to Buffer_Tail doπ write(Byte(Ptr(Seg0040,t)^):4);π end;π clreol;π writeln;π writeln(Byte(Ptr(Seg0040,Buffer_Head)^):3);π writeln(Byte(Ptr(Seg0040,Buffer_Tail)^):3);π writeln(Byte(Ptr(Seg0040,Buffer_Start)^):3);π writeln(Byte(Ptr(Seg0040,Buffer_End)^):3);ππ writeln;π for t:=ofs(Buffer_Head) to ofs(Buffer_Tail) doπ write(Byte(Ptr(seg(Buffer_Head),t)^):3);ππ until FALSE;π{endless Loop - Use Ctrl-Break to stop (you might have to reboot ifπyou run BP under Windows.}ππend.π